package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.common.Constants;
import com.example.service.MFileService;
import com.example.utils.DateUtils;
import com.example.utils.ExcelUtils;
import com.example.utils.PathUils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("file")
public class MFileController {

    @Autowired
    private MFileService mFileService;


    @GetMapping("list")
    public Object getMFileController(){
        return mFileService.list();
    }

    @PostMapping("upload")
    public Object uploadFile(MultipartFile multipartFile) throws Exception{
        String fileName=multipartFile.getOriginalFilename();
       String path= PathUils.getUploadPath(fileName);
       multipartFile.transferTo(new File(path));
       return "上传";
    }


}
